﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;

namespace Sinacor.Infra.UI.Controls.SmartClient
{
    public class SinacorNavigationPath : ItemsControl
    {
        protected override DependencyObject GetContainerForItemOverride()
        {
            return new SinacorNavigationPathItem();
        }

        protected override bool IsItemItsOwnContainerOverride(object item)
        {
            return item is SinacorNavigationPathItem;
        }

        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);

            ((SinacorNavigationPathItem)element).IsLast = this.ItemContainerGenerator.IndexFromContainer(element) == this.Items.Count - 1;
        }
    }

    public class SinacorNavigationPathItem : ContentControl
    {
        private static readonly DependencyPropertyKey IsLastKey = DependencyProperty.RegisterReadOnly("IsLast", typeof(bool), typeof(SinacorNavigationPathItem), new FrameworkPropertyMetadata(false));
        public static readonly DependencyProperty IsLastProperty = IsLastKey.DependencyProperty;

        public bool IsLast
        {
            get { return (bool)GetValue(IsLastProperty); }
            internal set { SetValue(IsLastKey, value); }
        }
    }
}
